home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1999 July: Mac OS SDK / Dev.CD Jul 99 SDK1.toast / Development Kits / Mac OS / QuickDraw3D 1.6 SDK / Mac SampleCode New for 1.6 / CullGroupSample / Source / Windows.c < prev   
Encoding:
C/C++ Source or Header  |  1999-05-18  |  4.6 KB  |  225 lines  |  [TEXT/CWIE]

  1. /****************************/
  2. /*        WINDOWS           */
  3. /* By Brian Greenstone      */
  4. /****************************/
  5.  
  6.  
  7. /***************/
  8. /* EXTERNALS   */
  9. /***************/
  10. #include     <Files.h>
  11. #include     <Dialogs.h>
  12.  
  13. #include     <QD3D.h>
  14.  
  15. #include    "myglobals.h"
  16. #include    "mywindows.h"
  17. #include    "misc.h"
  18.  
  19.  
  20. extern    Boolean        gShowContentStructure,gSaveTextToFile;
  21. extern    FSSpec        gStreamFSSpec;
  22. extern    short        gStreamRefNum;
  23.  
  24.  
  25. /****************************/
  26. /*    CONSTANTS             */
  27. /****************************/
  28.  
  29.  
  30. /**********************/
  31. /*     VARIABLES      */
  32. /**********************/
  33.  
  34. Rect        gSizeRect;
  35. short        gHtab = 10;
  36.  
  37.  
  38.  
  39.  
  40.  
  41. /*********************** DUMP GWORLD **********************/
  42. //
  43. //    
  44. //   
  45.  
  46. void DumpGWorld(GWorldPtr thisWorld, WindowPtr thisWindow)
  47. {
  48. Rect        tempRect;
  49. GrafPtr        oldPort;
  50. PixMapHandle pm;
  51.  
  52.     DoLockPixels(thisWorld);
  53.  
  54.     GetPort(&oldPort);
  55.     pm = GetGWorldPixMap(thisWorld);    
  56.     if ((pm == nil) | (*pm == nil) )
  57.         DoAlert("\pPixMap Handle or Ptr = Null?!");
  58.  
  59.     SetPort(thisWindow);
  60.             
  61.     tempRect = thisWindow->portRect;
  62.             
  63.     ForeColor(blackColor);
  64.     BackColor(whiteColor);
  65.         
  66.     CopyBits((BitMap *)*pm,&(qd.thePort->portBits),
  67.             &(thisWorld->portRect),&tempRect,srcCopy,0);
  68.  
  69.     SetPort(oldPort);
  70. }
  71.  
  72. /*********************** DUMP GWORLD 2 **********************/
  73. //
  74. //    copies to a destination RECT
  75. //
  76.  
  77. void DumpGWorld2(GWorldPtr thisWorld, WindowPtr thisWindow,Rect *destRect)
  78. {
  79. PixMapHandle pm;
  80.  
  81.     DoLockPixels(thisWorld);
  82.  
  83.     pm = GetGWorldPixMap(thisWorld);    
  84.     if ((pm == nil) | (*pm == nil) )
  85.         DoAlert("\pPixMap Handle or Ptr = Null?!");
  86.  
  87.     ForeColor(blackColor);
  88.     BackColor(whiteColor);
  89.         
  90.     CopyBits((BitMap *)*pm,&(thisWindow->portBits),
  91.             destRect,destRect,srcCopy,0);
  92.  
  93.     DoUnlockPixels(thisWorld);
  94. }
  95.  
  96. /*********************** DUMP GWORLD 3 **********************/
  97. //
  98. //    copies RECT to RECT
  99. //
  100.  
  101. void DumpGWorld3(GWorldPtr thisWorld, WindowPtr thisWindow,Rect *srcRect,Rect *destRect)
  102. {
  103. PixMapHandle pm;
  104.  
  105.     DoLockPixels(thisWorld);
  106.  
  107.     pm = GetGWorldPixMap(thisWorld);    
  108.     if ((pm == nil) | (*pm == nil) )
  109.         DoAlert("\pPixMap Handle or Ptr = Null?!");
  110.  
  111.     ForeColor(blackColor);
  112.     BackColor(whiteColor);
  113.         
  114.     CopyBits((BitMap *)*pm,&(thisWindow->portBits),
  115.             srcRect,destRect,srcCopy,0);
  116.  
  117. //    DoUnlockPixels(thisWorld);
  118. }
  119.  
  120.  
  121. /*********************** DUMP GWORLD TO GWORLD **********************/
  122. //
  123. //    copies RECT to RECT
  124. //
  125.  
  126. void DumpGWorldToGWorld(GWorldPtr thisWorld, GWorldPtr destWorld,Rect *srcRect,Rect *destRect)
  127. {
  128. PixMapHandle pm,pm2;
  129. GDHandle    oldGD;
  130. GWorldPtr    oldGW;
  131.  
  132.     GetGWorld (&oldGW,&oldGD);
  133.     SetGWorld(destWorld,nil);    
  134.     ForeColor(blackColor);
  135.     BackColor(whiteColor);
  136.  
  137.     SetGWorld(thisWorld,nil);    
  138.     ForeColor(blackColor);
  139.     BackColor(whiteColor);
  140.  
  141.     DoLockPixels(destWorld);
  142.     DoLockPixels(thisWorld);
  143.  
  144.     pm = GetGWorldPixMap(thisWorld);    
  145.     if ((pm == nil) | (*pm == nil) )
  146.         DoAlert("\pPixMap Handle or Ptr = Null?!");
  147.  
  148.     pm2 = GetGWorldPixMap(destWorld);    
  149.     if ((pm2 == nil) | (*pm2 == nil) )
  150.         DoAlert("\pPixMap Handle or Ptr = Null?!");
  151.  
  152.         
  153.     CopyBits((BitMap *)*pm,(BitMap *)*pm2,
  154.             srcRect,destRect,srcCopy,0);
  155.  
  156.     SetGWorld(oldGW,oldGD);                                // restore gworld
  157.  
  158. }
  159.  
  160.  
  161.  
  162. /******************* DO LOCK PIXELS **************/
  163.  
  164. void DoLockPixels(GWorldPtr world)
  165. {
  166. PixMapHandle pm;
  167.     
  168.     pm = GetGWorldPixMap(world);
  169.     if (LockPixels(pm) == false)
  170.         DoFatalAlert("\pPixMap Went Bye,Bye?!");
  171. }
  172.  
  173.  
  174. /***************** DO UNLOCK PIXELS **************/
  175.  
  176. void DoUnlockPixels(GWorldPtr world)
  177. {
  178.     PixMapHandle pm;
  179.     
  180.         pm = GetGWorldPixMap(world);
  181.         UnlockPixels(pm);
  182. }
  183.  
  184.  
  185. /*==============================================================================
  186. * Dobold ()
  187. * this is the user item procedure to make the thick outline around the default
  188. * button (assumed to be item 1)
  189. *=============================================================================*/
  190.  
  191. pascal void DoBold (WindowPtr dlogPtr, short item)
  192. {
  193. short        itype;
  194. Handle        ihandle;
  195. Rect        irect;
  196.  
  197.  
  198.     GetDialogItem (dlogPtr, item, &itype, (Handle *)&ihandle, &irect);    /* get the buttons rect */
  199.     PenSize (3, 3);                                            /* make thick lines    */
  200.     InsetRect (&irect, -4, -4);                            /* grow rect a little   */
  201.     FrameRoundRect (&irect, 16, 16);                        /* frame the button now */
  202.     PenNormal ();
  203. }
  204.  
  205. /*==============================================================================
  206. * DoOutline ()
  207. * this is the user item procedure to make the thin outline around the given useritem
  208. *=============================================================================*/
  209.  
  210. pascal void DoOutline (WindowPtr dlogPtr, short item)
  211. {
  212. short        itype;
  213. Handle        ihandle;
  214. Rect        irect;
  215.  
  216.     GetDialogItem (dlogPtr, item, &itype, (Handle *)&ihandle, &irect);    // get the user item's rect 
  217.     FrameRect (&irect);                        // frame the button now 
  218.     PenNormal();
  219. }
  220.  
  221.  
  222.  
  223.  
  224.  
  225.